<? require_once("sitemap.php"); ?>
<html>
	<title><? echo (":" . $HTTP_SERVER_VARS['REMOTE_USER'] . ": ". $Botname); ?>'s EL-BOT Command Management</title>
<body>
	<h1><? echo ($Botname); ?>'s EL-BOT Command Management</h1>
	<form method="post" action="<? echo $_SERVER['PHP_SELF'] ?>"><input type="submit" name="submit" value="RELOAD"><input type="hidden" name="action" value="refresh"></form>
<?
		if(isset($_POST['id']))
		{
			$id=intval(mysql_real_escape_string($_POST['id']));
			if(isset($_POST['disabled']))
				$disabled=1;
			else
				$disabled=0;
			$sql = "UPDATE commands SET id='$id', disabled='$disabled' WHERE id='$id' AND botid='$botid';";
			$result2 = mysql_query($sql,$db);
			echo (mysql_error());
			dumppost($HTTP_SERVER_VARS['REMOTE_USER']);
		}
		$result = mysql_query("SELECT id, name, requriedrank, disabled, description FROM commands WHERE botid='$botid' ORDER BY requriedrank, name",$db);
		echo (mysql_error());
	?>
    
	<h2>Bot Commands:</h2>
        <table border="1" cellpadding="0" cellspacing="0">
                <tr bgcolor="Gray">
                        <td>name</td>
                        <td>Required Rank</td>
                        <td>disabled</td>
                        <td>description</td>
				<td>Update</td>
                </tr>
                <?
                        while ($myrow = mysql_fetch_row($result))
				{
					if(stristr($myrow[4],"Unused at present")=="")
					{
                ?>
                        <form method='POST' action='<? echo $_SERVER['PHP_SELF'] ?>'>
					<tr>
					<input type='hidden' name='id' value='<?echo ($myrow[0])?>'>
	                        <td><?echo ($myrow[1])?></td>
      	                  <td align='right'><?echo ($myrow[2])?></td>
            	            <td><input type='checkbox' name='disabled'<? if($myrow[3] != 0) echo " checked"; ?>></td>
	                        <td><? if($myrow[4]!="") echo ($myrow[4]); else echo "No description"; ?></td>
					<td><input type='submit' name='action' value='Update'></td>
					</tr>
				</form>
                <?
                        	}
				}
                ?>
        </table>
</body>
</html>
